<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>v-model</title>
    <script src="vue.js"></script>
</head>
<body>
<div id="app">
    姓名:<input type="text" id="username" v-model="user.username"><br>
    密码:<input type="password" id="password" v-model="user.password"><br>
    <input type="button" @click="fun" value="获取">
</div>
<script>
    new Vue({
        el:'#app', //表示当前vue对象接管了div区域
        data:{
            user:{username:"",password:""}
        },
        methods:{
            fun:function(){
                alert(this.user.username+" "+this.user.password);
                this.user.username="tom";
                this.user.password="11111111";
            }
        }
    });
</script>
</body>
</html>